package com.example.mobile2032021606168xmy0427classtest2;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class ParkingRVAdapter extends RecyclerView.Adapter<ParkingRVAdapter.ViewHolder>{
    private List<Parking>list;
    public ParkingRVAdapter(List<Parking>list){
        this.list=list;
    }
    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvName, tvDis, tvSeat, tvAddress, tvPrice, btnMore;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            tvName = itemView.findViewById(R.id.tv_item_name);
            tvDis = itemView.findViewById(R.id.tv_item_dis);
            tvSeat = itemView.findViewById(R.id.tv_item_seat);
            tvAddress = itemView.findViewById(R.id.tv_item_address);
            tvPrice = itemView.findViewById(R.id.tv_item_price);
            btnMore = itemView.findViewById(R.id.btn_item_more);
        }
    }
    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_parking,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        Parking parking=list.get(position);
        holder.tvName.setText(parking.getName());
        holder.tvDis.setText(parking.getDis());
        holder.tvSeat.setText(String.valueOf(parking.getSeat()));
        holder.tvAddress.setText(parking.getAddress());
        holder.tvPrice.setText(parking.getPrice());
        holder.btnMore.setText(parking.getMore());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    }

